package com.ruicar.afs.cloud.basic.common.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruicar.afs.cloud.basic.common.entity.BasicAffiliatedUnit;
import com.ruicar.afs.cloud.basic.common.service.BasicAffiliatedUnitService;
import com.ruicar.afs.cloud.common.aspect.DataAccess;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xudongdong
 * @date 2020-06-16
 */
@Slf4j
@RestController
@RequestMapping("/custAnchorInfo")
@AllArgsConstructor
public class BasicAffiliatedUnitController {

    private BasicAffiliatedUnitService basicAffiliatedUnitService;

    @ApiOperation(value = "根据合同号码查询挂靠信息")
    @PostMapping("/getCustAnchorInfo")
    public IResponse getCustAnchorInfo(@RequestParam("contractNo") String contractNo) {
        BasicAffiliatedUnit basicAffiliatedUnit = basicAffiliatedUnitService.getOne(Wrappers.<BasicAffiliatedUnit>lambdaQuery().
                eq(BasicAffiliatedUnit::getContractNo, contractNo));
        return new IResponse().setData(basicAffiliatedUnit);
    }
}
